package com.ruoyi.web.ydz.service.impl;

import java.util.List;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.web.ydz.mapper.NewsDiseaseMapper;
import com.ruoyi.web.ydz.domain.NewsDisease;
import com.ruoyi.web.ydz.service.INewsDiseaseService;

/**
 * 新闻疾病关联Service业务层处理
 * 
 * @author DRX
 * @date 2024-10-31
 */
@Service
public class NewsDiseaseServiceImpl implements INewsDiseaseService 
{
    @Autowired
    private NewsDiseaseMapper newsDiseaseMapper;

    /**
     * 查询新闻疾病关联
     * 
     * @param id 新闻疾病关联主键
     * @return 新闻疾病关联
     */
    @Override
    public NewsDisease selectNewsDiseaseById(Long id)
    {
        return newsDiseaseMapper.selectNewsDiseaseById(id);
    }

    /**
     * 查询新闻疾病关联列表
     * 
     * @param newsDisease 新闻疾病关联
     * @return 新闻疾病关联
     */
    @Override
    public List<NewsDisease> selectNewsDiseaseList(NewsDisease newsDisease)
    {
        return newsDiseaseMapper.selectNewsDiseaseList(newsDisease);
    }

    /**
     * 新增新闻疾病关联
     * 
     * @param newsDisease 新闻疾病关联
     * @return 结果
     */
    @Override
    public int insertNewsDisease(NewsDisease newsDisease)
    {
        SysUser user = SecurityUtils.getLoginUser().getUser();
        newsDisease.setCreateTime(DateUtils.getNowDate());
        newsDisease.setCreateBy(user.getUserName());
        newsDisease.setCreateName(user.getNickName());
        return newsDiseaseMapper.insertNewsDisease(newsDisease);
    }

    /**
     * 修改新闻疾病关联
     * 
     * @param newsDisease 新闻疾病关联
     * @return 结果
     */
    @Override
    public int updateNewsDisease(NewsDisease newsDisease)
    {
        SysUser user = SecurityUtils.getLoginUser().getUser();
        newsDisease.setUpdateBy(user.getNickName());
        newsDisease.setUpdateName(user.getUserName());
        newsDisease.setUpdateTime(DateUtils.getNowDate());
        return newsDiseaseMapper.updateNewsDisease(newsDisease);
    }

    /**
     * 批量删除新闻疾病关联
     * 
     * @param ids 需要删除的新闻疾病关联主键
     * @return 结果
     */
    @Override
    public int deleteNewsDiseaseByIds(Long[] ids)
    {
        return newsDiseaseMapper.deleteNewsDiseaseByIds(ids);
    }

    /**
     * 删除新闻疾病关联信息
     * 
     * @param id 新闻疾病关联主键
     * @return 结果
     */
    @Override
    public int deleteNewsDiseaseById(Long id)
    {
        return newsDiseaseMapper.deleteNewsDiseaseById(id);
    }

    public int deleteNewsDiseaseByNewsId(Long newsId)
    {
        return newsDiseaseMapper.deleteNewsDiseaseByNewsId(newsId);
    }

}
